
export function bubbleSort (nums: number[]) {

    const len = nums.length;

    for (let i = len-1; i > 0; i--) {
        for (let j = 0; j < i; j++) {
            if (nums[j] > nums[j+1]) swap(nums, j, j+1);
        }
    }

    return nums;
}

function swap (nums: number[], i: number, j: number) {
    const temp = nums[i];
    nums[i] = nums[j];
    nums[j] = temp;
}

